---
layout: "default"
title: "removeAll"
description: "Swift documentation for 'removeAll': Remove all elements from x."
keywords: "removeAll,func,swift,documentation"
root: "/v1.2"
---

<div class="declaration" id="func-removeall-c_-rangereplaceablecollectiontype-inout_-c-keepcapacity_-bool">
<a class="toggle-link" data-toggle="collapse" href="#comment-func-removeall-c_-rangereplaceablecollectiontype-inout_-c-keepcapacity_-bool">func <wbr>removeAll&lt;C : RangeReplaceableCollectionType&gt;(<wbr>inout:<wbr> C, keepCapacity: Bool)</a>
        
<div class="comment collapse" id="comment-func-removeall-c_-rangereplaceablecollectiontype-inout_-c-keepcapacity_-bool"><div class="p">
    <p>Remove all elements from <code>x</code></p>

<p>Invalidates all indices with respect to <code>x</code>.</p>

<p><strong><code>keepCapacity</code></strong>, if <code>true</code>, is a non-binding request to
   avoid releasing storage, which can be a useful optimization
   when <code>x</code> is going to be grown again.</p>

<p>Complexity: O(<code>count(x)</code>).</p>

    <h4>Declaration</h4>    
    <code class="language-swift">func removeAll&lt;C : RangeReplaceableCollectionType&gt;(inout x: C, keepCapacity: Bool = default)</code>
    
    
</div></div>
</div>
